

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

class Solution2 {
    private static int n;
    private static HashMap<Integer, List<Integer>> graph;
    private static int x;
    private static int y;
    private static int k;

    private static boolean[] used;
    private static int depth;
    private static int res;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        sc.nextLine();
        String[] s = sc.nextLine().trim().split(" ");
        /*邻接表解法*/
        graph = new HashMap<>();
        for (String temp : s) {
            String[] s_temp = temp.trim().split(",");
            int i = Integer.parseInt(s_temp[0]);
            int j = Integer.parseInt(s_temp[1]);
            if (graph.containsKey(i)) graph.get(i).add(j);
            else {
                List<Integer> list = new LinkedList<>();
                list.add(j);
                graph.put(i, list);
            }
        }
        x = sc.nextInt();
        y = sc.nextInt();
        k = sc.nextInt();
        used = new boolean[n+1];
        depth = 0;
        res = 0;
        dfs(x);
        System.out.println(res);
    }

    public static void dfs(int station) {
        if (depth <= k+1 && station == y) res++;
        if (depth < k+1 && station != y) {
            for (int temp : graph.get(station)) {
                if(!used[temp]) {
                    used[temp] = true;
                    depth++;
                    dfs(temp);
                    depth--;
                    used[temp] = false;
                }
            }
        }
    }
}
